/* eslint-disable */
import Vue from 'vue'
import App from './App.vue'
import Alloylever from 'alloylever'

import api from '@/api'
import global from '@/utils/global'
import { Base64 } from 'js-base64'
import { router } from '@/router'
import { Lazyload, Skeleton, Toast,Icon,Dialog } from 'vant'
import FastClick from 'fastclick'
import VueClipboard from 'vue-clipboard2'
import 'amfe-flexible'
import storeLocal from 'storejs'
const DS = require('dsbridge')

Vue.use(Lazyload, {
    preLoad: 1.3,
    error: 'https://h5.dhcc.wang/loading.png',
    loading: 'https://h5.dhcc.wang/loading.png',
    attempt: 1
})
Vue.use(Icon).use(Skeleton).use(Toast).use(Base64).use(VueClipboard).use(Dialog).use(api)
const VConsole = require('vconsole')
// new VConsole()
if (process.env.NODE_ENV === 'development') {
    const VConsole = require('vconsole')
    new VConsole()
}

Alloylever.config({
    cdn: 'https://unpkg.com/vconsole/dist/vconsole.min.js',
    reportUrl: "",
    reportPrefix: 'h5',
    reportKey: 'msg',
    otherReport: {
        uin: 'sys error'
    },
    entry: "#entry"
})

let globalData = {}
DS.call('DS.getClientAppState', (res) => {
    const resData = JSON.parse(res)
    globalData.statusBarH = Number(resData.statusH) //状态栏高度
    globalData.showCloseIcon = !resData.isHomeTab   //判断是否装修在app底部隐藏关闭按钮，true:隐藏，false：不隐藏
    globalData.isCheckMode = resData.isCheckMode    // true:IOS审核模式,fasle:非审核模式
    globalData.systemType = resData.AppType
})
Vue.prototype.globalData = globalData

Vue.prototype.Global = global

FastClick.prototype.focus = function (targetElement) {
    var length;
    if (globalData.systemType == 'iOS' && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 &&
        targetElement.type !== 'time' && targetElement.type !== 'month') {
        length = targetElement.value.length;
        targetElement.focus();
        targetElement.setSelectionRange(length, length);
    } else {
        targetElement.focus();
    }
}

if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function () {
        FastClick.attach(document.body)
    }, false)
}
Vue.filter('formateTime', function (data,format='Y-M-D h:m:s') {
	return global.formatTime(data,format)
})

Vue.filter('getDateDiff', function (timestamp) {
    return global.getDateDiff(timestamp)
})
import navBar from './components/navBar.vue'
Vue.component('nav-bar', navBar)
import backTop from './components/backTop.vue'
Vue.component('backTop', backTop)
import noData from './components/noData.vue'
Vue.component('noData', noData)

const testGroup = ['ab8c37','a03e07']
const xid = global.getUrlName('xid')
let debug = false
if (testGroup.includes(xid)) {
    debug = true
}
Vue.prototype.isDebug = debug

Vue.prototype.$DB = storeLocal
Vue.prototype.$common = global
Vue.prototype.DS = DS
Vue.config.productionTip = false

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')
